package com.talent.controller;

import com.talent.common.Result;
import com.talent.pojo.dto.HomeSettingsDTO;
import com.talent.pojo.entity.Category;
import com.talent.pojo.vo.HomeSettingsVO;
import com.talent.service.CategoryService;
import com.talent.service.HomeService;
import com.talent.service.MenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import java.util.List;

/**
 * 首页管理控制器
 */
@RestController
@RequestMapping("/api/home")
@Slf4j
public class HomeController {

    @Autowired
    private HomeService homeService;

    /**
     * 获取首页设置
     */
    @GetMapping("/settings")
    public Result<HomeSettingsVO> getHomeSettings() {
        log.info("获取首页设置");
        HomeSettingsVO homeSettings = homeService.getHomeSettings();
        return Result.success(homeSettings);
    }

    /**
     * 保存首页设置
     */
    @PostMapping("/settings")
    public Result<String> saveHomeSettings(@Valid @RequestBody HomeSettingsDTO homeSettingsDTO) {
        log.info("保存首页设置：{}", homeSettingsDTO);
        homeService.saveHomeSettings(homeSettingsDTO);
        return Result.success("保存成功");
    }
}
